import tornado.web
import sae.const
import tornado.database
import os.path
import time

from article import article
from connection import Connection

class ArticleHandler(tornado.web.RequestHandler):
    def get(self):
        self.render("publish.html")
    def post(self):
        content = self.get_argument("article", "")
        if content == "":
        	self.render("publish.html")
        	return
        db = Connection(sae.const.MYSQL_HOST+":"+sae.const.MYSQL_PORT,sae.const.MYSQL_DB, sae.const.MYSQL_USER, sae.const.MYSQL_PASS, 30)
        db.execute("INSERT INTO article (content) VALUES ('" + content + "')")

        self.redirect("/")
